package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.Organization;
//huibati

/**
 * 系统用户表
 */
@Entity
@JsonApiResource(type = "userPrivate")
@Table(name = "t_s_base_user")
@Inheritance(strategy = InheritanceType.JOINED)
public class UserPrivate extends BaseEntity {
	private String code;// 编码
	private String loginName;// 用户名
	protected Role role;// 角色
	private String name;// 真实姓名
	private String entName;// 企业名称
	private String password;// 用户密码
	private String avatar;// 头像文件名
	private String desc;// 自我描述
	private Short status;// 状态1：在线,2：离线,0：禁用
	private Short sex;// 性别,1男2女
	private String staffTel;// 电话号码
	private String staffMail;// 邮箱
	private String weixin;// 微信号
	private String qqnum;// QQ
	private String address;// 地址
	private Integer age;// 年龄
	private String introduce;// 简介
	// private UserAgent agentinfo;// 坐席信息信息-华为
	private String regWay;// 注册途径
	private String verifyFailReason;// 审核失败原因
	private String inviter;

	private Integer createTime;// 创建时间
	private Integer updateTime; // 更新时间
	private String remark; // 备注
	private Organization org;

	private Employee employee;// 员工

	private Dicttype staffStatus;

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.SELECT)
	// huibati
	@JoinColumn(name = "staffStatus_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getStaffStatus() {
		return staffStatus;
	}

	public void setStaffStatus(Dicttype staffStatus) {
		this.staffStatus = staffStatus;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "employee_id", foreignKey = @ForeignKey(name = "null"))
	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "org_id", foreignKey = @ForeignKey(name = "null"))
	public Organization getOrg() {
		return org;
	}

	public void setOrg(Organization org) {
		this.org = org;
	}

	@Column(name = "code")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "login_name")
	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(final String loginName) {
		this.loginName = loginName;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "role_id", foreignKey = @ForeignKey(name = "null"))
	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(final String name) {
		this.name = name;
	}

	@Column(name = "ent_name")
	public String getEntName() {
		return entName;
	}

	public void setEntName(final String entName) {
		this.entName = entName;
	}

	@Column(name = "password")
	public String getPassword() {
		return password;
	}

	public void setPassword(final String password) {
		this.password = password;
	}

	@Column(name = "avatar")
	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(final String avatar) {
		this.avatar = avatar;
	}

	@Column(name = "descr")
	public String getDesc() {
		return desc;
	}

	public void setDesc(final String desc) {
		this.desc = desc;
	}

	@Column(name = "status")
	public Short getStatus() {
		return status;
	}

	public void setStatus(final Short status) {
		this.status = status;
	}

	@Column(name = "sex")
	public Short getSex() {
		return sex;
	}

	public void setSex(final Short sex) {
		this.sex = sex;
	}

	@Column(name = "staffTel")
	public String getStaffTel() {
		return staffTel;
	}

	public void setStaffTel(final String phone) {
		this.staffTel = phone;
	}

	@Column(name = "staffMail")
	public String getStaffMail() {
		return staffMail;
	}

	public void setStaffMail(final String email) {
		this.staffMail = email;
	}

	@Column(name = "weixin")
	public String getWeixin() {
		return weixin;
	}

	public void setWeixin(final String weixin) {
		this.weixin = weixin;
	}

	@Column(name = "qqnum")
	public String getQqnum() {
		return qqnum;
	}

	public void setQqnum(String qqnum) {
		this.qqnum = qqnum;
	}

	@Column(name = "address")
	public String getAddress() {
		return address;
	}

	public void setAddress(final String address) {
		this.address = address;
	}

	@Column(name = "age")
	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	@Column(name = "introduce")
	public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public void setInviter(String inviter) {
		this.inviter = inviter;
	}

	/*
	 * @JsonApiToOne
	 * 
	 * @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	 * 
	 * @JoinColumn(name = "agentinfo",foreignKey = @ForeignKey(name = "null"))
	 * 
	 * @Fetch(FetchMode.JOIN) public UserAgent getAgentinfo() { return
	 * agentinfo; }
	 * 
	 * public void setAgentinfo(UserAgent agentinfo) { this.agentinfo =
	 * agentinfo; }
	 */

	@Column(name = "reg_way")
	public String getRegWay() {
		return regWay;
	}

	public void setRegWay(String regWay) {
		this.regWay = regWay;
	}

	@Column(name = "verify_fail_reason")
	public String getVerifyFailReason() {
		return verifyFailReason;
	}

	public void setVerifyFailReason(String verifyFailReason) {
		this.verifyFailReason = verifyFailReason;
	}

	@Column(name = "inviter")
	public String getInviter() {
		return inviter;
	}

	/*
	 * @JsonApiToMany
	 * 
	 * @OneToMany(mappedBy = "inviteUser")
	 * 
	 * @JsonManagedReference public List<UserPrivate> getInvitees() { return
	 * invitees; }
	 * 
	 * public void setInvitees(List<UserPrivate> invitees) { this.invitees =
	 * invitees; }
	 */

	@Column(name = "create_time")
	public Integer getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Integer createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_time")
	public Integer getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Integer updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}